<?php
include("db/connect.php");
$sql="select * from cartmaterial,material where cartmaterial.mat_id=material.mat_id and ordermat_id='0'";
$query=mysql_query($sql);
?>

    <div id="cartdiv">
    <form id="form1">
    <div>

	<table border="1">
	<tr>
	<td>รหัสวัตถุดิบ</td>
	<td>ชื่อวัตถุดิบ</td>
	<td>ราคา</td>
	<td>จำนวน</td>
	<td>รวม</td>
	<td>ลบ</td>
	</tr>
	<?php 
	$countRow=0;
	$sum=0;
	while($result2=mysql_fetch_array($query)){
	$countRow++;
	$sum+=$result2["mat_price"]*$result2["mat_qty"];
	?>
	<tr>
	<td><?php echo $result2["mat_id"];?></td>
	<td><?php echo $result2["mat_name"];?></td>
	<td><?php echo $result2["mat_price"];?></td>
	<td><?php echo $result2["mat_qty"];?></td>
	<td><?php echo $result2["mat_price"]*$result2["mat_qty"];?></td>
	<td><a href="#" onclick="Javascript:dltcartmaterial(<?php echo $result2["mat_id"]?>,'per');">ลบ</a></td>
	</tr>
	 <?php }?>
	 <tr>
	 <td colspan="4">รวมทั้งหมด</td>
	 <td><?php echo $sum;?></td>
	 <td>บาท</td>
	 </tr>
	</table>
    </div>
    </form>
	<div>
	
	</div>
	</div>